typedef struct node
{
	int data;
	struct node *child[maxsize];//一个结点可能有不止两个邻接点
}*Node;
typedef struct arcnode
{
	int adjvex;
	struct arcnode *next;
}*Arcnode;
typedef struct Vnode
{
	int data;
	Arcnode firstnode;
}Vnode;
typedef struct graph
{
	Vnode edges[maxsize];
	int n,e;
}*graph;
Arcnode FistNeighbor(graph G,Node p)
{
	return G->edges[p->data].firstnode;
}
Arcnode NextNeighbor(graph G,Node p,Arcnode q)
{
	Arcnode t=G->edges[p->data].firstnode;
	while(t!=NULL)
	{
		if(t->adjvex!=q->adjvex)
			t=t->next;
		else
			break;
	}
	return t->next;
}
Node getTree(graph g,int v)//按广度优先遍历生成一个支撑树
{
	Node queue[maxsize];
	Node root=(Node)malloc(sizeof(struct node));
	root->data=v;
	int visited[maxsize]={0};
	visited[v]=1;
	int front=0,rear=0;
	queue[rear++]=root;//入队
	Node p;
	while(front!=rear)
	{
		p=queue[front++];//出队
		int i=0;
		for(Arcnode q=FistNeighbor(g,p);q!=NULL;q=NextNeighbor(g,p,q))//遍历p的所有邻接顶点
		{
			if(visited[q->adjvex]==0)
			{
				p->child[i]=(Node)malloc(sizeof(struct node));  //将邻接顶点转换成树节点
				p->child[i]->data=q->adjvex;
				visited[q->adjvex]=1; //标记访问
				queue[rear++]=p->child[i]; //入队
				i++;
			}
		}
	}
	return root;//返回支撑树
}
